package cn.gov.pbc.gd.credit.web.controller.menu;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.liu.jbase.ResultVo;
import com.liu.jbase.controller.impl.BaseControllerImpl;

import cn.gov.pbc.gd.credit.user.service.menu.IMenuService;
import cn.gov.pbc.gd.credit.vo.menu.MenuVo;
import cn.gov.pbc.gd.credit.vo.menu.ResMenuVo;

@Controller
@RequestMapping("/menu")	
public class MenuController extends BaseControllerImpl<ResMenuVo, MenuVo, IMenuService> {

	@Autowired
	private IMenuService menuService;
	
	@ResponseBody
    @RequestMapping("/tree")
	public ResultVo<List<ResMenuVo>> tree(MenuVo menuVo, HttpServletRequest request) throws Exception {

		return menuService.treeMenuList(menuVo, request);
	}
	
    @RequestMapping("/tree/page")
	public String treePage(MenuVo menuVo, Model model, HttpServletRequest request) throws Exception {

		model.addAttribute("result", menuService.treeMenuList(menuVo, request));
		
		return "menu/page";
	}
    
    @ResponseBody
    @RequestMapping("/cache/reload")
	public ResultVo<List<ResMenuVo>> cacheRelaod(MenuVo menuVo, HttpServletRequest request) throws Exception {

		return menuService.cacheTreeMenu(new MenuVo(), request);
	}
}
